package com.danco.planner;

import java.util.ArrayList;

import com.danco.planner.essences.*;
import com.danco.planner.essences.arraylists.*;

public class CoursesPlanner {

	protected CoursesList coursesList;
	public CoursesList getCoursesList() {
		return coursesList;
	}

	protected SpeakersList speakersList;
	public SpeakersList getSpeakersList() {
		return speakersList;
	}
	
	protected LecturesList lecturesList;
	public LecturesList getLecturesList() {
		return lecturesList;
	}
	
	protected StudentsList studentsList;
	public StudentsList getStudentsList() {
		return studentsList;	
	}

	public CoursesPlanner() {
		super();
		
		this.coursesList = new CoursesList();
		this.speakersList = new SpeakersList();
		this.lecturesList = new LecturesList();
		this.studentsList = new StudentsList();
	}
	
	public boolean addSpeaker(Speaker speaker) {
		return speakersList.add(speaker);
	}
	public boolean addLecture(Lecture lecture) {
		return lecturesList.add(lecture);
	}
	public boolean addStudent(Student student) {
		return studentsList.add(student);
	}
	public boolean addCourse(Course course) {
		return coursesList.add(course);
	}
	
	public boolean removeSpeaker(Speaker speaker) {
		return speakersList.remove(speaker);
	}
	public boolean removeLecture(Lecture lecture) {
		return lecturesList.remove(lecture);
	}
	public boolean removeStudent(Student student) {
		return studentsList.remove(student);
	}
	public boolean removeCourse(Course course) {
		return coursesList.remove(course);
	}
	
	public void removeAllSpeakers() {
		speakersList.clear();
	}
	public void removeAllLectures() {
		lecturesList.clear();
	}
	public void removeAllStudents() {
		studentsList.clear();
	}
	public void removeAllCourses() {
		coursesList.clear();
	}
	
	public boolean addCourseWithSpeakerLecturesAndStudents(Course course, Speaker speaker,
														   ArrayList<Lecture> lectures,
														   ArrayList<Student> students) {
		if (course == null) return false;
		if (!coursesList.contains(course)) coursesList.add(course);
		course.addSpeaker(speaker);
		
		for (Student student : students) {
			course.addStudent(student);
		}
		for (Lecture lecture : lectures) {
			course.addLecture(lecture);
		}
		
		return true;
	}
	
	@Override
	public String toString() {
		
		return String.format("Courses:\n\t%1$2s\nSpeakers:\n\t%2$2s\nStudents:\n\t%3$2s\n",
							coursesList.toString(), speakersList.toString(), studentsList.toString());
	}
}
